﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebApplication1.Classes;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections.Generic;


namespace WebApplication1
{
    public partial class Poisk : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void ButtonSearchClick(object sender, EventArgs e)
        {
            string Сon = ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;
                SqlConnection sqlCon = new SqlConnection(Сon);
            try
            {
                sqlCon.Open();
                Int32 id_flat;
                id_flat = Convert.ToInt32(TextBoxSearch.Text);

                string strQuery = "SELECT * FROM Contract where IdFlat=" + id_flat;
                DataSet ds = new DataSet();
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = new SqlCommand(strQuery, sqlCon);
                sda.Fill(ds, "Contract");
                GridViewSearch.DataSource = ds.Tables["Contract"];
                this.DataBind();
                sqlCon.Close();
            }
            catch (Exception ex)
            {
                Server.Transfer("Error.aspx?error=" + ex.Message);
                sqlCon.Close();
                
            }

        }

    }

}
